home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 September (IDG) / Sep99.iso / Shareware World / Comms & Internet / LinkConverter 1.1.2 / Dialog Director v0.7 / Examples / Calc Total.as < prev    next >
Encoding:
Text File  |  1998-01-12  |  1.6 KB  |  44 lines  |  [TEXT/ToyS]

  1. property calcDialog : {size:[250, 176], name:"Calculate Total", style:movable dialog, contents:[¬
  2.     {class:push button, name:"Done", bounds:[180, 115, 240, 135]}, ¬
  3.     {class:push button, name:"Calc.", bounds:[180, 146, 240, 166]}, ¬
  4.     {class:static text, bounds:[60, 150, 155, 166]}, ¬
  5.     {class:text field, name:"1995", bounds:[60, 25, 155, 41], name bounds:[10, 24, 50, 40]}, ¬
  6.     {class:text field, name:"1996", bounds:[60, 50, 155, 66], name bounds:[10, 50, 50, 66]}, ¬
  7.     {class:text field, name:"1997", bounds:[60, 75, 155, 91], name bounds:[10, 76, 50, 92]}, ¬
  8.     {class:text field, name:"1998", bounds:[60, 100, 155, 116], name bounds:[10, 102, 50, 118]}, ¬
  9.     {class:text field, name:"1999", bounds:[60, 125, 155, 141], name bounds:[10, 128, 50, 144]}, ¬
  10.     {class:static text, contents:"Year", bounds:[10, 4, 50, 20]}, ¬
  11.     {class:static text, contents:"Amount", bounds:[60, 4, 200, 20]}, ¬
  12.     {class:static text, contents:"Total", bounds:[10, 150, 50, 166]}, ¬
  13.     {class:group box, bounds:[60, 148, 155, 149]}, ¬
  14.     {class:group box, bounds:[60, 166, 155, 166]} ¬
  15.         ], default item:2}
  16.  
  17. dd install with grayscale
  18. set d to dd make dialog calcDialog
  19. dd set value of items 4 thru 8 of d to [200, 300, 400, 500, 100]
  20. DoCalc(d)
  21. repeat
  22.     set i to dd interact with user
  23.     if i = 1 then exit repeat
  24.     if i = 2 then DoCalc(d)
  25. end repeat
  26. dd uninstall
  27.  
  28. on DoCalc(d)
  29.     set tot to 0
  30.     set dVals to dd get value of items 4 thru 8 of d
  31.     set i to 4
  32.     repeat with n in dVals
  33.         try
  34.             set tot to tot + n as number
  35.             set i to i + 1
  36.         on error
  37.             dd set selection of item i of d to [0, -1]
  38.             beep 2
  39.             set tot to "?"
  40.             exit repeat
  41.         end try
  42.     end repeat
  43.     dd set contents of item 3 of d to tot
  44. end DoCalc